package week4.num.ExceptionDemo01.neueduTotal.card;

import java.util.Arrays;

public class Player{
    /**
     * 玩家的id
     */
    private String id;
    /**
     * 玩家的名称
     */
    private String name;
    /**
     * 玩家的手牌
     */
    Card[] cards = {};

    public Player() {
    }

    public Player(String name, String id) {
        this.name = name;
        this.id = id;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Card[] getCards() {
        return cards;
    }

    public void setCards(Card[] cards) {
        this.cards = cards;
    }

    /**
     * 重写toString方法
     * @return 玩家的信息和手牌
     */
    @Override
    public String toString() {
        return "id:" + id + "name:" + name + "cards:" + Arrays.toString(cards);
    }
    public void add(Card card){
        this.cards=Arrays.copyOf(cards,cards.length+1);
        cards[cards.length-1]=card;
    }


}
